package com.gao.String;

import java.util.Scanner;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class StringTest2 {
    /*
            需求：键盘录入一个字符串，统计该字符中大写字母字符，小写字母字符，数字字符出现的次数（不考虑其他字符）

            例如：aAb3&c2B*4CD1

     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您的字符串：");
        String zifu = sc.nextLine();
        char[] zifuCharArray = zifu.toCharArray();
        int count1 = 0; //小写字母数量
        int count2 = 0;//大写字母数量
        int count3 = 0;//数字数量
        for (int i = 0; i < zifuCharArray.length; i++) {
            if (zifuCharArray[i] >= 'a' && zifuCharArray[i] <= 'z') {
                count1++;
            } else if (zifuCharArray[i] >= 'A' && zifuCharArray[i] <= 'Z') {
                count2++;
            } else if (zifuCharArray[i] >= '0' && zifuCharArray[i] <= '9') {
                count3++;
            }
        }
        System.out.println("小写字母数量：" + count1);
        System.out.println("大写字母数量：" + count2);
        System.out.println("数字数量：" + count3);

    }
}
